

	 
 $(document).ready(function() {
		 
	 var teachers =$.ajax(
			 {url: 'teacherList.htm', 
				 async: false, 
				 success: function(data, result) {
					    
					 if (!result) alert('Failure to retrieve the teachers.');
						 
					 }			 }).responseText;

	 var grades =$.ajax(
			 {url: 'gradeList.htm', 
				 async: false, 
				 success: function(data, result) { 
					 if (!result) alert('Failure to retrieve the teachers.');
						 
					 },  
				failure: function(data, result) {
				    
					    alert('Failure to retrieve the Countries.');
						window.alert(data);

					 }
			 }).responseText;
	 	
	 jQuery("#gridClass").jqGrid({ 
		 url:'classInformation.htm?standardID=1',
		 editurl:"addClass.htm",
		  datatype: "json", 
		  colNames:['StandardID','sectionID','Section Name', 'Class Teacher', 'Comments'], 
		  colModel:[ 
		  {name:'StandardID',index:'StandardID',editable:true,width:15,  hidden: true, viewable: false  },
		  {name:'sectionID',index:'sectionID',editable:true,width:15,  hidden: true, viewable: false  }, 
		  {name:'sectionName',index:'sectionName', width:100, resizable: true, hidden: false, viewable: true,editable:true,editoptions:{size:20}}, 
		  {name:'classTeacher',index:'classTeacher', width:100, align:"right", resizable: true, hidden: false, viewable: true,editable:true,edittype:"select", editoptions:{size:20, value: teachers}}, 
		  {name:'comments',index:'comments', width:110,align:"right",editable:true,editoptions:{size:20}} ],
		  rowNum:30,
		  rowList:[10,20,30], 
		  pager: '#pageClass', 
		  sortname: 'id', 
		  viewrecords: true, 
		  sortorder: "desc", 
		  rownumbers: true,
		  height : 300,
		  width: 680, 
		  caption: "Class Information" }); 
	 var addOptions = { reloadAfterSubmit:false, 
			 beforeShowForm: function(form) { $('#tr_Class', form).show(); }, 
    		 onclickSubmit : function(eparams) {  
			}};
     var deleteOptions = { reloadAfterSubmit:false, url : "deleteClass.htm",
    		 onclickSubmit : function(eparams) { 
					var allUserIDs = "";
    			    var selectedrows = jQuery("#gridClass").jqGrid('getGridParam', 'selarrrow'); 
    			    // we can use all the grid methods here
    			    //to obtain some data 
    			    for(var row in selectedrows)
    			    	{
    			        var userID = 	jQuery('#gridClass').jqGrid('getCell',selectedrows[row],'userid');
    			        allUserIDs = allUserIDs + userID + ";" 
    			    	}
    			    eparams.url = eparams.url + "?userID= " + allUserIDs; 
    			}};
     var editOptions = {reloadAfterSubmit:false, 
    		 onclickSubmit : function(eparams) { 
					 
 			}};
     
     jQuery("#gridClass").jqGrid('navGrid', '#pageClass', { add: true, view: true, del: true, edit: true },
    	     editOptions, // edit options
             addOptions , // add options
             deleteOptions, // del options
             {}, // search options
             {   // vew options
             beforeShowForm: function(form) {
              
             }
         }); 
 });


	function createGrades()
	{
	
		$.ajax(
				 {url: 'addGrades.htm?sectionGrade=3&gradeRange=1', 
					 async: false, 
					 success: function(data, result) {
						    
						 if (!result) alert('Failure to retrieve the teachers.');
							 
						 }			 })
						 return false;
	}

	function gradeSectionChanged(sel) {
		 
		 $("#gridClass").setGridParam(
	             { 
	                     url: 'classInformation.htm?standardID='+sel.value
	             }
	             ).trigger("reloadGrid")
	 }
	window.onload = function() {

		window.alert($("standardRange") + "asds");
		$("classDisplayDiv").style.visibility = 'hidden'; 
		$("standardRange").style.visibility = 'none';

		}
